Skip to contentSkip to conversation

Change in openvpn[master]: Install host routes with onlink scope iroutes for ifconfig-push routes

Openvpn-devel In review plaisthos (Code Review) 2 participants 36 messages Sep 15, 2025 – Oct 29, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1757957943000.I83295e00d1a756dfa44050b0a4493095fb050fff@...2715...

#1 lore raw

Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email

to review the following change.

Change subject: Install host routes with onlink scope iroutes for ifconfig-push routes
......................................................................

Install host routes with onlink scope iroutes for ifconfig-push routes

Additional IP addresses for hosts that lie outside the primary network of the configured device need to be added to the operating system to ensure that traffic for these IP addresses is also directed to the VPN.

For Linux it is import that these extra routes are routes with scope link rather than static since otherwise routes via these IP addresses, like iroute, will not work.

Change-Id I83295e00d1a756dfa44050b0a4493095fb050fff

---
M doc/man-sections/server-options.rst
M src/openvpn/dco.c
M src/openvpn/mroute.h
M src/openvpn/multi.c
M src/openvpn/multi.h

5 files changed, 153 insertions(+), 5 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1192/1

doc/man-sections/server-options.rst +3 -0
index ccc1374..bb58330 100644
@@ -314,6 +314,9 @@
   3.  Use ``--ifconfig-pool`` allocation for dynamic IP (last
       choice).
 
+  When DCO is enabled, OpenVPN will install a /32 route for the local IP
+  address
+
 --ifconfig-ipv6-push args
   for ``--client-config-dir`` per-client static IPv6 interface
   configuration, see ``--client-config-dir`` and ``--ifconfig-push`` for
src/openvpn/dco.c +35 -2
index 70a8c0a..8280fbb 100644
@@ -670,8 +670,14 @@
         dco_win_add_iroute_ipv6(&c->c1.tuntap->dco, addr->v6.addr, addr->netbits,
                                 c->c2.tls_multi->peer_id);
 #else
+        const struct in6_addr *gateway = &mi->context.c2.push_ifconfig_ipv6_local;
+        if (addr->type & MR_ONLINK_ADDR)
+        {
+            gateway = NULL;
+        }
+
         net_route_v6_add(&m->top.net_ctx, &addr->v6.addr, addr->netbits,
-                         &mi->context.c2.push_ifconfig_ipv6_local, c->c1.tuntap->actual_name, 0,
+                         gateway, c->c1.tuntap->actual_name, 0,
                          DCO_IROUTE_METRIC);
 #endif
     }
@@ -682,7 +688,13 @@
                                 c->c2.tls_multi->peer_id);
 #else
         in_addr_t dest = htonl(addr->v4.addr);
-        net_route_v4_add(&m->top.net_ctx, &dest, addr->netbits, &mi->context.c2.push_ifconfig_local,
+        const in_addr_t *gateway = &mi->context.c2.push_ifconfig_local;
+        if (addr->type & MR_ONLINK_ADDR)
+        {
+            gateway = NULL;
+        }
+
+        net_route_v4_add(&m->top.net_ctx, &dest, addr->netbits, gateway,
                          c->c1.tuntap->actual_name, 0, DCO_IROUTE_METRIC);
 #endif
     }
@@ -713,6 +725,18 @@
                              DCO_IROUTE_METRIC);
 #endif
         }
+
+        /* Check if we added the local network as /32 route as it was not in
+         * the normal on link scope */
+        if (multi_check_push_ifconfig_extra_route(mi))
+        {
+#if defined(_WIN32)
+            dco_win_del_iroute_ipv4(&c->c1.tuntap->dco, push_ifconfig_local, 32);
+#else
+            net_route_v4_del(&m->top.net_ctx, &mi->context.c2.push_ifconfig_local, 32,
+                             NULL, c->c1.tuntap->actual_name, 0, DCO_IROUTE_METRIC);
+#endif
+        }
     }
 
     if (mi->context.c2.push_ifconfig_ipv6_defined)
@@ -727,6 +751,15 @@
                              DCO_IROUTE_METRIC);
 #endif
         }
+        if (multi_check_push_ifconfig_ipv6_extra_route(mi))
+        {
+#if defined(_WIN32)
+            dco_win_del_iroute_ipv6(&c->c1.tuntap->dco, &mi->context.c2.push_ifconfig_ipv6_local, 128);
+#else
+            net_route_v6_del(&m->top.net_ctx, &mi->context.c2.push_ifconfig_ipv6_local, 128,
+                             NULL, c->c1.tuntap->actual_name, 0, DCO_IROUTE_METRIC);
+#endif
+        }
     }
 #endif /* if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(_WIN32) */
 }
src/openvpn/mroute.h +4 -0
index 5b0c694..f4e54ca 100644
@@ -20,6 +20,7 @@
  *  with this program; if not, see <https://www.gnu.org/licenses/>.
  */
 
+
 #ifndef MROUTE_H
 #define MROUTE_H
 
@@ -74,6 +75,9 @@
 /* Address type mask indicating that proto # is part of address */
 #define MR_WITH_PROTO 32
 
+/* MRoute is an on link/scope address  ather than a route */
+#define MR_ONLINK_ADDR 64
+
 struct mroute_addr
 {
     uint8_t len;     /* length of address */
src/openvpn/multi.c +91 -3

118 lines not on this page · raw message

src/openvpn/multi.h +20 -0
index 087c0e6..5ec3904 100644
@@ -666,6 +666,26 @@
     return ret;
 }
 
+/**
+ * Determines if the ifconfig_push_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_extra_route(struct multi_instance *mi);
+
+/**
+ * Determines if the ifconfig_ipv6_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_ipv6_extra_route(struct multi_instance *mi);
+
 /*
  * Check for signals.
  */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes with onlink scope iroutes for ifconfig-push routes
......................................................................

Patch Set 1:

(1 comment)

Patchset:

PS1:
Currently only tested on Linux. Need to still test the other DCO platforms.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Mon, 15 Sep 2025 17:40:48 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email

to look at the new patch set (#2).

Change subject: Install host routes with onlink scope iroutes for ifconfig-push routes
......................................................................

Install host routes with onlink scope iroutes for ifconfig-push routes

Additional IP addresses for hosts that lie outside the primary network of the configured device need to be added to the operating system to ensure that traffic for these IP addresses is also directed to the VPN.

For Linux it is important that these extra routes are routes with scope link rather than static since otherwise routes via these IP addresses, like iroute, will not work.

Change-Id I83295e00d1a756dfa44050b0a4493095fb050fff

---
M doc/man-sections/server-options.rst
M src/openvpn/dco.c
M src/openvpn/mroute.h
M src/openvpn/multi.c
M src/openvpn/multi.h

5 files changed, 153 insertions(+), 5 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1192/2

doc/man-sections/server-options.rst +3 -0
index ccc1374..bb58330 100644
@@ -314,6 +314,9 @@
   3.  Use ``--ifconfig-pool`` allocation for dynamic IP (last
       choice).
 
+  When DCO is enabled, OpenVPN will install a /32 route for the local IP
+  address
+
 --ifconfig-ipv6-push args
   for ``--client-config-dir`` per-client static IPv6 interface
   configuration, see ``--client-config-dir`` and ``--ifconfig-push`` for
src/openvpn/dco.c +35 -2
index 70a8c0a..8280fbb 100644
@@ -670,8 +670,14 @@
         dco_win_add_iroute_ipv6(&c->c1.tuntap->dco, addr->v6.addr, addr->netbits,
                                 c->c2.tls_multi->peer_id);
 #else
+        const struct in6_addr *gateway = &mi->context.c2.push_ifconfig_ipv6_local;
+        if (addr->type & MR_ONLINK_ADDR)
+        {
+            gateway = NULL;
+        }
+
         net_route_v6_add(&m->top.net_ctx, &addr->v6.addr, addr->netbits,
-                         &mi->context.c2.push_ifconfig_ipv6_local, c->c1.tuntap->actual_name, 0,
+                         gateway, c->c1.tuntap->actual_name, 0,
                          DCO_IROUTE_METRIC);
 #endif
     }
@@ -682,7 +688,13 @@
                                 c->c2.tls_multi->peer_id);
 #else
         in_addr_t dest = htonl(addr->v4.addr);
-        net_route_v4_add(&m->top.net_ctx, &dest, addr->netbits, &mi->context.c2.push_ifconfig_local,
+        const in_addr_t *gateway = &mi->context.c2.push_ifconfig_local;
+        if (addr->type & MR_ONLINK_ADDR)
+        {
+            gateway = NULL;
+        }
+
+        net_route_v4_add(&m->top.net_ctx, &dest, addr->netbits, gateway,
                          c->c1.tuntap->actual_name, 0, DCO_IROUTE_METRIC);
 #endif
     }
@@ -713,6 +725,18 @@
                              DCO_IROUTE_METRIC);
 #endif
         }
+
+        /* Check if we added the local network as /32 route as it was not in
+         * the normal on link scope */
+        if (multi_check_push_ifconfig_extra_route(mi))
+        {
+#if defined(_WIN32)
+            dco_win_del_iroute_ipv4(&c->c1.tuntap->dco, push_ifconfig_local, 32);
+#else
+            net_route_v4_del(&m->top.net_ctx, &mi->context.c2.push_ifconfig_local, 32,
+                             NULL, c->c1.tuntap->actual_name, 0, DCO_IROUTE_METRIC);
+#endif
+        }
     }
 
     if (mi->context.c2.push_ifconfig_ipv6_defined)
@@ -727,6 +751,15 @@
                              DCO_IROUTE_METRIC);
 #endif
         }
+        if (multi_check_push_ifconfig_ipv6_extra_route(mi))
+        {
+#if defined(_WIN32)
+            dco_win_del_iroute_ipv6(&c->c1.tuntap->dco, &mi->context.c2.push_ifconfig_ipv6_local, 128);
+#else
+            net_route_v6_del(&m->top.net_ctx, &mi->context.c2.push_ifconfig_ipv6_local, 128,
+                             NULL, c->c1.tuntap->actual_name, 0, DCO_IROUTE_METRIC);
+#endif
+        }
     }
 #endif /* if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(_WIN32) */
 }
src/openvpn/mroute.h +4 -0
index 5b0c694..f4e54ca 100644
@@ -20,6 +20,7 @@
  *  with this program; if not, see <https://www.gnu.org/licenses/>.
  */
 
+
 #ifndef MROUTE_H
 #define MROUTE_H
 
@@ -74,6 +75,9 @@
 /* Address type mask indicating that proto # is part of address */
 #define MR_WITH_PROTO 32
 
+/* MRoute is an on link/scope address  ather than a route */
+#define MR_ONLINK_ADDR 64
+
 struct mroute_addr
 {
     uint8_t len;     /* length of address */
src/openvpn/multi.c +91 -3

118 lines not on this page · raw message

src/openvpn/multi.h +20 -0
index 087c0e6..5ec3904 100644
@@ -666,6 +666,26 @@
     return ret;
 }
 
+/**
+ * Determines if the ifconfig_push_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_extra_route(struct multi_instance *mi);
+
+/**
+ * Determines if the ifconfig_ipv6_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_ipv6_extra_route(struct multi_instance *mi);
+
 /*
  * Check for signals.
  */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset

#4 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email

to look at the new patch set (#3).

Change subject: Install host routes with onlink scope iroutes for ifconfig-push routes
......................................................................

Install host routes with onlink scope iroutes for ifconfig-push routes

Additional IP addresses for hosts that lie outside the primary network of the configured device need to be added to the operating system to ensure that traffic for these IP addresses is also directed to the VPN.

For Linux it is important that these extra routes are routes using scope link rather than static since otherwise routes via these IP addresses, like iroute, will not work.

Tested using a server with ccd:

   openvpn --server 10.33.0.0 255.255.192.0 --server-ipv6 fd00:f00f::1/64  --client-config-dir ~/ccd [...]

and a client with lwipvonpn and the following ccd file:

iroute-ipv6 FD00:F00F:CAFE::1001/64 ifconfig-ipv6-push FD00:F00F:D00D::77/64
push "setenv-safe ifconfig_ipv6_local_2 FD00:F00F:CAFE::1001" push "setenv-safe ifconfig_ipv6_netbits_2 64"

iroute 10.234.234.0 255.255.255.0 ifconfig-push 10.11.12.13 255.255.255.0 push "setenv-safe ifconfig_local_2 10.234.234.12" push "setenv-safe ifconfig_netmask_2 255.255.255.0"

Change-Id I83295e00d1a756dfa44050b0a4493095fb050fff

---
M doc/man-sections/server-options.rst
M src/openvpn/dco.c
M src/openvpn/mroute.h
M src/openvpn/multi.c
M src/openvpn/multi.h

5 files changed, 156 insertions(+), 5 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1192/3

doc/man-sections/server-options.rst +6 -0
index ccc1374..3cd84dd 100644
@@ -314,6 +314,9 @@
   3.  Use ``--ifconfig-pool`` allocation for dynamic IP (last
       choice).
 
+  When DCO is enabled, OpenVPN will install a /32 route for the local IP
+  address
+
 --ifconfig-ipv6-push args
   for ``--client-config-dir`` per-client static IPv6 interface
   configuration, see ``--client-config-dir`` and ``--ifconfig-push`` for
@@ -324,6 +327,9 @@
 
      ifconfig-ipv6-push ipv6addr/bits ipv6remote
 
+  When DCO is enabled, OpenVPN will install a /128 route for the local IP
+  address.
+
 --multihome
   Configure a multi-homed UDP server. This option needs to be used when a
   server has more than one IP address (e.g. multiple interfaces, or
src/openvpn/dco.c +35 -2
index 70a8c0a..bbcda1d 100644
@@ -670,8 +670,14 @@
         dco_win_add_iroute_ipv6(&c->c1.tuntap->dco, addr->v6.addr, addr->netbits,
                                 c->c2.tls_multi->peer_id);
 #else
+        const struct in6_addr *gateway = &mi->context.c2.push_ifconfig_ipv6_local;
+        if (addr->type & MR_ONLINK_ADDR)
+        {
+            gateway = NULL;
+        }
+
         net_route_v6_add(&m->top.net_ctx, &addr->v6.addr, addr->netbits,
-                         &mi->context.c2.push_ifconfig_ipv6_local, c->c1.tuntap->actual_name, 0,
+                         gateway, c->c1.tuntap->actual_name, 0,
                          DCO_IROUTE_METRIC);
 #endif
     }
@@ -682,7 +688,13 @@
                                 c->c2.tls_multi->peer_id);
 #else
         in_addr_t dest = htonl(addr->v4.addr);
-        net_route_v4_add(&m->top.net_ctx, &dest, addr->netbits, &mi->context.c2.push_ifconfig_local,
+        const in_addr_t *gateway = &mi->context.c2.push_ifconfig_local;
+        if (addr->type & MR_ONLINK_ADDR)
+        {
+            gateway = NULL;
+        }
+
+        net_route_v4_add(&m->top.net_ctx, &dest, addr->netbits, gateway,
                          c->c1.tuntap->actual_name, 0, DCO_IROUTE_METRIC);
 #endif
     }
@@ -713,6 +725,18 @@
                              DCO_IROUTE_METRIC);
 #endif
         }
+
+        /* Check if we added the local network as /32 route as it was not in
+         * the normal on link scope */
+        if (multi_check_push_ifconfig_extra_route(mi))
+        {
+#if defined(_WIN32)
+            dco_win_del_iroute_ipv4(&c->c1.tuntap->dco, mi->context.c2.push_ifconfig_local, 32);
+#else
+            net_route_v4_del(&m->top.net_ctx, &mi->context.c2.push_ifconfig_local, 32,
+                             NULL, c->c1.tuntap->actual_name, 0, DCO_IROUTE_METRIC);
+#endif
+        }
     }
 
     if (mi->context.c2.push_ifconfig_ipv6_defined)
@@ -727,6 +751,15 @@
                              DCO_IROUTE_METRIC);
 #endif
         }
+        if (multi_check_push_ifconfig_ipv6_extra_route(mi))
+        {
+#if defined(_WIN32)
+            dco_win_del_iroute_ipv6(&c->c1.tuntap->dco, mi->context.c2.push_ifconfig_ipv6_local, 128);
+#else
+            net_route_v6_del(&m->top.net_ctx, &mi->context.c2.push_ifconfig_ipv6_local, 128,
+                             NULL, c->c1.tuntap->actual_name, 0, DCO_IROUTE_METRIC);
+#endif
+        }
     }
 #endif /* if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(_WIN32) */
 }
src/openvpn/mroute.h +4 -0
index 5b0c694..f4e54ca 100644
@@ -20,6 +20,7 @@
  *  with this program; if not, see <https://www.gnu.org/licenses/>.
  */
 
+
 #ifndef MROUTE_H
 #define MROUTE_H
 
@@ -74,6 +75,9 @@
 /* Address type mask indicating that proto # is part of address */
 #define MR_WITH_PROTO 32
 
+/* MRoute is an on link/scope address  ather than a route */
+#define MR_ONLINK_ADDR 64
+
 struct mroute_addr
 {
     uint8_t len;     /* length of address */
src/openvpn/multi.c +91 -3

118 lines not on this page · raw message

src/openvpn/multi.h +20 -0
index 087c0e6..5ec3904 100644
@@ -666,6 +666,26 @@
     return ret;
 }
 
+/**
+ * Determines if the ifconfig_push_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_extra_route(struct multi_instance *mi);
+
+/**
+ * Determines if the ifconfig_ipv6_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_ipv6_extra_route(struct multi_instance *mi);
+
 /*
  * Check for signals.
  */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset

#5 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes with onlink scope iroutes for ifconfig-push routes
......................................................................

Patch Set 3:

(1 comment)

Patchset:

PS1:

Quoted 1 line

Currently only tested on Linux. Need to still test the other DCO platforms.

Linux and FreeBSD work fine. Windows testing still pending.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 16 Sep 2025 14:35:32 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: plaisthos <[email protected]...>
Gerrit-MessageType: comment

#6 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email

to look at the new patch set (#4).

Change subject: Install host routes with onlink scope iroutes for ifconfig-push routes
......................................................................

Install host routes with onlink scope iroutes for ifconfig-push routes

Additional IP addresses for hosts that lie outside the primary network of the configured device need to be added to the operating system to ensure that traffic for these IP addresses is also directed to the VPN.

For Linux it is important that these extra routes are routes using scope link rather than static since otherwise routes via these IP addresses, like iroute, will not work.

Tested using a server with ccd:

   openvpn --server 10.33.0.0 255.255.192.0 --server-ipv6 fd00:f00f::1/64  --client-config-dir ~/ccd [...]

and a client with lwipvonpn and the following ccd file:

iroute-ipv6 FD00:F00F:CAFE::1001/64 ifconfig-ipv6-push FD00:F00F:D00D::77/64
push "setenv-safe ifconfig_ipv6_local_2 FD00:F00F:CAFE::1001" push "setenv-safe ifconfig_ipv6_netbits_2 64"

iroute 10.234.234.0 255.255.255.0 ifconfig-push 10.11.12.13 255.255.255.0 push "setenv-safe ifconfig_local_2 10.234.234.12" push "setenv-safe ifconfig_netmask_2 255.255.255.0"

Change-Id I83295e00d1a756dfa44050b0a4493095fb050fff

---
M doc/man-sections/server-options.rst
M src/openvpn/dco.c
M src/openvpn/mroute.h
M src/openvpn/multi.c
M src/openvpn/multi.h

5 files changed, 156 insertions(+), 5 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1192/4

doc/man-sections/server-options.rst +6 -0
index ccc1374..3cd84dd 100644
@@ -314,6 +314,9 @@
   3.  Use ``--ifconfig-pool`` allocation for dynamic IP (last
       choice).
 
+  When DCO is enabled, OpenVPN will install a /32 route for the local IP
+  address
+
 --ifconfig-ipv6-push args
   for ``--client-config-dir`` per-client static IPv6 interface
   configuration, see ``--client-config-dir`` and ``--ifconfig-push`` for
@@ -324,6 +327,9 @@
 
      ifconfig-ipv6-push ipv6addr/bits ipv6remote
 
+  When DCO is enabled, OpenVPN will install a /128 route for the local IP
+  address.
+
 --multihome
   Configure a multi-homed UDP server. This option needs to be used when a
   server has more than one IP address (e.g. multiple interfaces, or
src/openvpn/dco.c +35 -2
index 70a8c0a..bbcda1d 100644
@@ -670,8 +670,14 @@
         dco_win_add_iroute_ipv6(&c->c1.tuntap->dco, addr->v6.addr, addr->netbits,
                                 c->c2.tls_multi->peer_id);
 #else
+        const struct in6_addr *gateway = &mi->context.c2.push_ifconfig_ipv6_local;
+        if (addr->type & MR_ONLINK_ADDR)
+        {
+            gateway = NULL;
+        }
+
         net_route_v6_add(&m->top.net_ctx, &addr->v6.addr, addr->netbits,
-                         &mi->context.c2.push_ifconfig_ipv6_local, c->c1.tuntap->actual_name, 0,
+                         gateway, c->c1.tuntap->actual_name, 0,
                          DCO_IROUTE_METRIC);
 #endif
     }
@@ -682,7 +688,13 @@
                                 c->c2.tls_multi->peer_id);
 #else
         in_addr_t dest = htonl(addr->v4.addr);
-        net_route_v4_add(&m->top.net_ctx, &dest, addr->netbits, &mi->context.c2.push_ifconfig_local,
+        const in_addr_t *gateway = &mi->context.c2.push_ifconfig_local;
+        if (addr->type & MR_ONLINK_ADDR)
+        {
+            gateway = NULL;
+        }
+
+        net_route_v4_add(&m->top.net_ctx, &dest, addr->netbits, gateway,
                          c->c1.tuntap->actual_name, 0, DCO_IROUTE_METRIC);
 #endif
     }
@@ -713,6 +725,18 @@
                              DCO_IROUTE_METRIC);
 #endif
         }
+
+        /* Check if we added the local network as /32 route as it was not in
+         * the normal on link scope */
+        if (multi_check_push_ifconfig_extra_route(mi))
+        {
+#if defined(_WIN32)
+            dco_win_del_iroute_ipv4(&c->c1.tuntap->dco, mi->context.c2.push_ifconfig_local, 32);
+#else
+            net_route_v4_del(&m->top.net_ctx, &mi->context.c2.push_ifconfig_local, 32,
+                             NULL, c->c1.tuntap->actual_name, 0, DCO_IROUTE_METRIC);
+#endif
+        }
     }
 
     if (mi->context.c2.push_ifconfig_ipv6_defined)
@@ -727,6 +751,15 @@
                              DCO_IROUTE_METRIC);
 #endif
         }
+        if (multi_check_push_ifconfig_ipv6_extra_route(mi))
+        {
+#if defined(_WIN32)
+            dco_win_del_iroute_ipv6(&c->c1.tuntap->dco, mi->context.c2.push_ifconfig_ipv6_local, 128);
+#else
+            net_route_v6_del(&m->top.net_ctx, &mi->context.c2.push_ifconfig_ipv6_local, 128,
+                             NULL, c->c1.tuntap->actual_name, 0, DCO_IROUTE_METRIC);
+#endif
+        }
     }
 #endif /* if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(_WIN32) */
 }
src/openvpn/mroute.h +4 -0
index 5b0c694..852ccb6 100644
@@ -20,6 +20,7 @@
  *  with this program; if not, see <https://www.gnu.org/licenses/>.
  */
 
+
 #ifndef MROUTE_H
 #define MROUTE_H
 
@@ -74,6 +75,9 @@
 /* Address type mask indicating that proto # is part of address */
 #define MR_WITH_PROTO 32
 
+/* MRoute is an on link/scope address rather than a route */
+#define MR_ONLINK_ADDR 64
+
 struct mroute_addr
 {
     uint8_t len;     /* length of address */
src/openvpn/multi.c +91 -3

118 lines not on this page · raw message

src/openvpn/multi.h +20 -0
index 087c0e6..5ec3904 100644
@@ -666,6 +666,26 @@
     return ret;
 }
 
+/**
+ * Determines if the ifconfig_push_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_extra_route(struct multi_instance *mi);
+
+/**
+ * Determines if the ifconfig_ipv6_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_ipv6_extra_route(struct multi_instance *mi);
+
 /*
  * Check for signals.
  */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset

#7 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

d12fk has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes with onlink scope iroutes for ifconfig-push routes
......................................................................

Patch Set 2:

(3 comments)

File doc/man-sections/server-options.rst:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/3599a99a_f568303b :
PS2, Line 317: When DCO is enabled, OpenVPN will install a /32 route for the local IP
Should this also be documented for ifconfig-ipv6-push?

File src/openvpn/mroute.h:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/dca75073_98b8eff0 :
PS2, Line 78: /* MRoute is an on link/scope address ather than a route */ Typo rather

File src/openvpn/multi.c:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/b815c5df_9c118436 :
PS2, Line 4347: /**
Doxygen is already in the header file

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: d12fk <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 16 Sep 2025 20:52:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

#8 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

ordex has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes with onlink scope iroutes for ifconfig-push routes
......................................................................

Patch Set 4: Code-Review+1

(12 comments)

Commit Message:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/6b060a08_b9b15038 :
PS4, Line 7: Install host routes with onlink scope iroutes for ifconfig-push routes to be honest, this title feels a bit cryptic 😄
maybe it can be simplified a little, since we have the longer description below?

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/955bcbc5_de33bffb :
PS4, Line 10: of the configured device need to be added to the operating system to
the subject for "need" is "Additional IP addresses", but I think you meant "a route to those IPs", right? So this sentence should be massaged a little.

Moreover, is ifconfig-push really creating an "Additional IP" or is it just substituting the IP assigned out of the server pool?

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/9e07abea_3c127d4d :
PS4, Line 15: iroute, will not work.
should we add "because the server does not have an address in the same network as these IPs assigned to the VPN interface" (some something alike)?

Just to make sure in 5 months from now we recall why we did this.

Patchset:

PS4:
patch looks good to me. I just have a few minor nitpicks..

File doc/man-sections/server-options.rst:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/a86c4865_793f1207 :
PS4, Line 318: address
s/for/to/
s/ /./

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/bff8681a_b8c91a88 :
PS4, Line 330: When DCO is enabled, OpenVPN will install a /128 route for the local IP
s/for/to/

File src/openvpn/dco.c:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/d9ae49b2_0ce9bbcd :
PS4, Line 729: /* Check if we added the local network as /32 route as it was not in
should we call it "client network", as "local" seems to be something local to the server

File src/openvpn/multi.h:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/c67d489a_5aa0fbc8 :
PS4, Line 672: *
forgot to document "mi"

File src/openvpn/multi.c:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/d08232ec_d390068e :
PS4, Line 1251: msg(D_MULTI_LOW, "MULTI: Adding /32 on-link route for route %s -> %s",
s/for route/for ifconfig-push/ ? (like you wrote in the ipv6 case)

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/bed1bbae_c70f9021 :
PS4, Line 1262: if (!primary)
for clarity sake, shouldn't this be an "else if"?
From a functional perspective it shouldn't make a difference.

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/8760fe93_46153291 :
PS4, Line 1315: if (!primary)
same

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/4a7ec029_5c48f9ed :
PS4, Line 4353: */
I think we normally put the doxygen in one place only (i.e. header file), so this can go.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: d12fk <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 16 Sep 2025 21:19:39 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#9 lore raw
In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, plaisthos.

ordex has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes with onlink scope iroutes for ifconfig-push routes
......................................................................

Patch Set 4:

(1 comment)

File doc/man-sections/server-options.rst:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/a7b6d431_9cacb904 :
PS2, Line 317: When DCO is enabled, OpenVPN will install a /32 route for the local IP

Quoted 1 line

Should this also be documented for ifconfig-ipv6-push?

@[email protected]... it's just a few lines below

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: d12fk <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Tue, 16 Sep 2025 21:20:33 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: d12fk <[email protected]...>
Gerrit-MessageType: comment

#10 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, ordex, plaisthos.

d12fk has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes with onlink scope iroutes for ifconfig-push routes
......................................................................

Patch Set 4:

(2 comments)

File doc/man-sections/server-options.rst:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/a01854be_05971411 :
PS2, Line 317: When DCO is enabled, OpenVPN will install a /32 route for the local IP

Quoted 1 line

@[email protected]... […]

Yeah, was looking at an old version.

File src/openvpn/mroute.h:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/8364575a_c2f0e56d :
PS2, Line 78: /* MRoute is an on link/scope address ather than a route */

Quoted 1 line

Typo rather

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: d12fk <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Tue, 16 Sep 2025 21:40:03 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: ordex <[email protected]...>
Comment-In-Reply-To: d12fk <[email protected]...>
Gerrit-MessageType: comment

#11 lore raw
In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, ordex.

plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes with onlink scope iroutes for ifconfig-push routes
......................................................................

Patch Set 4:

(13 comments)

Commit Message:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/db3aa800_00ffb55b :
PS4, Line 7: Install host routes with onlink scope iroutes for ifconfig-push routes

Quoted 1 line

to be honest, this title feels a bit cryptic 😄 […]

I tried to make it a bit easier to understand what is happening here.

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/8599ca43_fae0473b :
PS4, Line 10: of the configured device need to be added to the operating system to

Quoted 1 line

the subject for "need" is "Additional IP addresses", but I think you meant "a route to those IPs", r […]

ifconfig-push can be used for both. To either pick a specific IP address of the pool or to specify an address outside of the pool. But pool is not really correct here either as we really care about --ifconfig here and not about --ifconfig-pool but --server typically sets to be the same.

File doc/man-sections/server-options.rst:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/86c25c1c_10f45ae8 :
PS2, Line 317: When DCO is enabled, OpenVPN will install a /32 route for the local IP

Quoted 1 line

Should this also be documented for ifconfig-ipv6-push?

I already documented. You seem to have commented on version 2 after I uploaded v4.

File doc/man-sections/server-options.rst:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/17f06b05_a6c4c15f :
PS4, Line 318: address

Quoted 1 line

s/for/to/ […]

Done

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/6b55d068_07d64a50 :
PS4, Line 330: When DCO is enabled, OpenVPN will install a /128 route for the local IP

Quoted 1 line

s/for/to/

Done

File src/openvpn/dco.c:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/b545dc09_22feb536 :
PS4, Line 729: /* Check if we added the local network as /32 route as it was not in

Quoted 1 line

should we call it "client network", as "local" seems to be something local to the server

Done

File src/openvpn/mroute.h:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/442f986d_d8c6b1d1 :
PS2, Line 78: /* MRoute is an on link/scope address ather than a route */

Quoted 1 line

Typo rather

fixed already in v4.

File src/openvpn/multi.h:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/413eed33_c08b5e0d :
PS4, Line 672: *

Quoted 1 line

forgot to document "mi"

Done

File src/openvpn/multi.c:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/f087988d_68fbfd53 :
PS2, Line 4347: /**

Quoted 1 line

Doxygen is already in the header file

Done

File src/openvpn/multi.c:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/8e1814c1_f9785b38 :
PS4, Line 1251: msg(D_MULTI_LOW, "MULTI: Adding /32 on-link route for route %s -> %s",

Quoted 1 line

s/for route/for ifconfig-push/ ? (like you wrote in the ipv6 case)

Done

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/8e6958ef_74bd7374 :
PS4, Line 1262: if (!primary)

Quoted 1 line

for clarity sake, shouldn't this be an "else if"? […]

Done

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/4d8bd6f0_6be3546b :
PS4, Line 1315: if (!primary)

Quoted 1 line

same

Done

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/de75b4bc_4f184632 :
PS4, Line 4353: */

Quoted 1 line

I think we normally put the doxygen in one place only (i.e. header file), so this can go.

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: d12fk <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Wed, 17 Sep 2025 10:19:40 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: ordex <[email protected]...>
Comment-In-Reply-To: d12fk <[email protected]...>
Gerrit-MessageType: comment

#12 lore raw
In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, plaisthos.

ordex has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes with onlink scope iroutes for ifconfig-push routes
......................................................................

Patch Set 4:

(3 comments)

Commit Message:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/e68f700d_fb964762 :
PS4, Line 7: Install host routes with onlink scope iroutes for ifconfig-push routes

Quoted 1 line

I tried to make it a bit easier to understand what is happening here.

how about:

DCO: install onlink host iroute when pushed IP is out of server network

?

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/e81bb1a9_d227e995 :
PS4, Line 10: of the configured device need to be added to the operating system to

Quoted 1 line

ifconfig-push can be used for both. […]

I agree with that, but what I meant in my comment is that we "need *routes* to be added" not IPs. In your text you're implying we need to add IPs "..to the operating system.."

File doc/man-sections/server-options.rst:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/c74c5864_8023ffde :
PS2, Line 317: When DCO is enabled, OpenVPN will install a /32 route for the local IP

Quoted 1 line

I already documented. You seem to have commented on version 2 after I uploaded v4.

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: d12fk <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Wed, 17 Sep 2025 11:01:39 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: plaisthos <[email protected]...>
Comment-In-Reply-To: ordex <[email protected]...>
Comment-In-Reply-To: d12fk <[email protected]...>
Gerrit-MessageType: comment

#13 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, ordex, plaisthos.

Hello flichtenheld, ordex,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email

to look at the new patch set (#5).

The following approvals got outdated and were removed:
Code-Review+1 by ordex

Change subject: Install host routes for ifconfig-push routes when DCO is enabled
......................................................................

Install host routes for ifconfig-push routes when DCO is enabled

ifconfig-push and ifconfig-ipv6-push can configure the IP address of a client. If this IP address lies inside the network that is configured on the ovpn/tun device this works as expected as the routing table point to the ovpn/tun interface. However, if the IP address
is outside that range, the IP packets are not forwarded to the ovpn/tun interface.

This patch adds logic to add host routes for these ifconfig-push/ifconfig-ipv6-push addresses to ensure that traffic for these IP addresses is also directed to the VPN.

For Linux it is important that these extra routes are routes using scope link rather than static since otherwise routes via these IP addresses, like iroute, will not work. On FreeBSD we also use interface routes as works and routes that target interfaces instead of IP addresses are less brittle.

Tested using a server with ccd:

   openvpn --server 10.33.0.0 255.255.192.0 --server-ipv6 fd00:f00f::1/64  --client-config-dir ~/ccd [...]

and a client with lwipvonpn and the following ccd file:

iroute-ipv6 FD00:F00F:CAFE::1001/64 ifconfig-ipv6-push FD00:F00F:D00D::77/64
push "setenv-safe ifconfig_ipv6_local_2 FD00:F00F:CAFE::1001" push "setenv-safe ifconfig_ipv6_netbits_2 64"

iroute 10.234.234.0 255.255.255.0 ifconfig-push 10.11.12.13 255.255.255.0 push "setenv-safe ifconfig_local_2 10.234.234.12" push "setenv-safe ifconfig_netmask_2 255.255.255.0"

This setups an ifconfig-push addresses outside the --server/--server-ipv6 network and additionally configures a iroute behind that client. The setenv-safe configure lwipovpn to use that additional IP addresses to allow testing via ping.

Change-Id I83295e00d1a756dfa44050b0a4493095fb050fff

---
M doc/man-sections/server-options.rst
M src/openvpn/dco.c
M src/openvpn/mroute.h
M src/openvpn/multi.c
M src/openvpn/multi.h

5 files changed, 157 insertions(+), 7 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1192/5

doc/man-sections/server-options.rst +8 -0
index ccc1374..9c7fa46 100644
@@ -314,6 +314,10 @@
   3.  Use ``--ifconfig-pool`` allocation for dynamic IP (last
       choice).
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig``, OpenVPN will install a /32 host route for the ``local``
+  IP address.
+
 --ifconfig-ipv6-push args
   for ``--client-config-dir`` per-client static IPv6 interface
   configuration, see ``--client-config-dir`` and ``--ifconfig-push`` for
@@ -324,6 +328,10 @@
 
      ifconfig-ipv6-push ipv6addr/bits ipv6remote
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig-ipv6``, OpenVPN will install a /128 host route for the
+  ``ipv6addr`` IP address.
+
 --multihome
   Configure a multi-homed UDP server. This option needs to be used when a
   server has more than one IP address (e.g. multiple interfaces, or
src/openvpn/dco.c +38 -2
index 70a8c0a..e533d65 100644
@@ -670,8 +670,14 @@
         dco_win_add_iroute_ipv6(&c->c1.tuntap->dco, addr->v6.addr, addr->netbits,
                                 c->c2.tls_multi->peer_id);
 #else
+        const struct in6_addr *gateway = &mi->context.c2.push_ifconfig_ipv6_local;
+        if (addr->type & MR_ONLINK_ADDR)
+        {
+            gateway = NULL;
+        }
+
         net_route_v6_add(&m->top.net_ctx, &addr->v6.addr, addr->netbits,
-                         &mi->context.c2.push_ifconfig_ipv6_local, c->c1.tuntap->actual_name, 0,
+                         gateway, c->c1.tuntap->actual_name, 0,
                          DCO_IROUTE_METRIC);
 #endif
     }
@@ -682,7 +688,13 @@
                                 c->c2.tls_multi->peer_id);
 #else
         in_addr_t dest = htonl(addr->v4.addr);
-        net_route_v4_add(&m->top.net_ctx, &dest, addr->netbits, &mi->context.c2.push_ifconfig_local,
+        const in_addr_t *gateway = &mi->context.c2.push_ifconfig_local;
+        if (addr->type & MR_ONLINK_ADDR)
+        {
+            gateway = NULL;
+        }
+
+        net_route_v4_add(&m->top.net_ctx, &dest, addr->netbits, gateway,
                          c->c1.tuntap->actual_name, 0, DCO_IROUTE_METRIC);
 #endif
     }
@@ -713,6 +725,18 @@
                              DCO_IROUTE_METRIC);
 #endif
         }
+
+        /* Check if we added a host route as the assigned client IP address was
+         * not in the on link scope defined by --ifconfig */
+        if (multi_check_push_ifconfig_extra_route(mi))
+        {
+#if defined(_WIN32)
+            dco_win_del_iroute_ipv4(&c->c1.tuntap->dco, mi->context.c2.push_ifconfig_local, 32);
+#else
+            net_route_v4_del(&m->top.net_ctx, &mi->context.c2.push_ifconfig_local, 32,
+                             NULL, c->c1.tuntap->actual_name, 0, DCO_IROUTE_METRIC);
+#endif
+        }
     }
 
     if (mi->context.c2.push_ifconfig_ipv6_defined)
@@ -727,6 +751,18 @@
                              DCO_IROUTE_METRIC);
 #endif
         }
+
+        /* Checked if we added a host route as the assigned client IP address was
+         * outside the --ifconfig-ipv6 tun interface config */
+        if (multi_check_push_ifconfig_ipv6_extra_route(mi))
+        {
+#if defined(_WIN32)
+            dco_win_del_iroute_ipv6(&c->c1.tuntap->dco, mi->context.c2.push_ifconfig_ipv6_local, 128);
+#else
+            net_route_v6_del(&m->top.net_ctx, &mi->context.c2.push_ifconfig_ipv6_local, 128,
+                             NULL, c->c1.tuntap->actual_name, 0, DCO_IROUTE_METRIC);
+#endif
+        }
     }
 #endif /* if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(_WIN32) */
 }
src/openvpn/mroute.h +4 -0
index 5b0c694..852ccb6 100644
@@ -20,6 +20,7 @@
  *  with this program; if not, see <https://www.gnu.org/licenses/>.
  */
 
+
 #ifndef MROUTE_H
 #define MROUTE_H
 
@@ -74,6 +75,9 @@
 /* Address type mask indicating that proto # is part of address */
 #define MR_WITH_PROTO 32
 
+/* MRoute is an on link/scope address rather than a route */
+#define MR_ONLINK_ADDR 64
+
 struct mroute_addr
 {
     uint8_t len;     /* length of address */
src/openvpn/multi.c +85 -5

113 lines not on this page · raw message

src/openvpn/multi.h +22 -0
index 087c0e6..bc58d38 100644
@@ -666,6 +666,28 @@
     return ret;
 }
 
+/**
+ * Determines if the ifconfig_push_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @param mi           The multi-instance to check this condition for
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_extra_route(struct multi_instance *mi);
+
+/**
+ * Determines if the ifconfig_ipv6_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_ipv6_extra_route(struct multi_instance *mi);
+
 /*
  * Check for signals.
  */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: d12fk <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-MessageType: newpatchset

#14 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, ordex, plaisthos.

Hello flichtenheld, ordex,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email

to look at the new patch set (#6).

Change subject: Install host routes for ifconfig-push routes when DCO is enabled
......................................................................

Install host routes for ifconfig-push routes when DCO is enabled

ifconfig-push and ifconfig-ipv6-push can configure the IP address of a client. If this IP address lies inside the network that is configured on the ovpn/tun device this works as expected as the routing table point to the ovpn/tun interface. However, if the IP address
is outside that range, the IP packets are not forwarded to the ovpn/tun interface.

This patch adds logic to add host routes for these ifconfig-push/ifconfig-ipv6-push addresses to ensure that traffic for these IP addresses is also directed to the VPN.

For Linux it is important that these extra routes are routes using scope link rather than static since otherwise routes via these IP addresses, like iroute, will not work. On FreeBSD we also use interface routes as works and routes that target interfaces instead of IP addresses are less brittle.

Tested using a server with ccd:

   openvpn --server 10.33.0.0 255.255.192.0 --server-ipv6 fd00:f00f::1/64  --client-config-dir ~/ccd [...]

and a client with lwipvonpn and the following ccd file:

iroute-ipv6 FD00:F00F:CAFE::1001/64 ifconfig-ipv6-push FD00:F00F:D00D::77/64
push "setenv-safe ifconfig_ipv6_local_2 FD00:F00F:CAFE::1001" push "setenv-safe ifconfig_ipv6_netbits_2 64"

iroute 10.234.234.0 255.255.255.0 ifconfig-push 10.11.12.13 255.255.255.0 push "setenv-safe ifconfig_local_2 10.234.234.12" push "setenv-safe ifconfig_netmask_2 255.255.255.0"

This setups an ifconfig-push addresses outside the --server/--server-ipv6 network and additionally configures a iroute behind that client. The setenv-safe configure lwipovpn to use that additional IP addresses to allow testing via ping.

Change-Id I83295e00d1a756dfa44050b0a4493095fb050fff

---
M doc/man-sections/server-options.rst
M src/openvpn/dco.c
M src/openvpn/mroute.h
M src/openvpn/multi.c
M src/openvpn/multi.h

5 files changed, 165 insertions(+), 7 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1192/6

doc/man-sections/server-options.rst +8 -0
index ccc1374..9c7fa46 100644
@@ -314,6 +314,10 @@
   3.  Use ``--ifconfig-pool`` allocation for dynamic IP (last
       choice).
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig``, OpenVPN will install a /32 host route for the ``local``
+  IP address.
+
 --ifconfig-ipv6-push args
   for ``--client-config-dir`` per-client static IPv6 interface
   configuration, see ``--client-config-dir`` and ``--ifconfig-push`` for
@@ -324,6 +328,10 @@
 
      ifconfig-ipv6-push ipv6addr/bits ipv6remote
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig-ipv6``, OpenVPN will install a /128 host route for the
+  ``ipv6addr`` IP address.
+
 --multihome
   Configure a multi-homed UDP server. This option needs to be used when a
   server has more than one IP address (e.g. multiple interfaces, or
src/openvpn/dco.c +46 -2

79 lines not on this page · raw message

src/openvpn/mroute.h +4 -0
index 5b0c694..852ccb6 100644
@@ -20,6 +20,7 @@
  *  with this program; if not, see <https://www.gnu.org/licenses/>.
  */
 
+
 #ifndef MROUTE_H
 #define MROUTE_H
 
@@ -74,6 +75,9 @@
 /* Address type mask indicating that proto # is part of address */
 #define MR_WITH_PROTO 32
 
+/* MRoute is an on link/scope address rather than a route */
+#define MR_ONLINK_ADDR 64
+
 struct mroute_addr
 {
     uint8_t len;     /* length of address */
src/openvpn/multi.c +85 -5

113 lines not on this page · raw message

src/openvpn/multi.h +22 -0
index 087c0e6..bc58d38 100644
@@ -666,6 +666,28 @@
     return ret;
 }
 
+/**
+ * Determines if the ifconfig_push_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @param mi           The multi-instance to check this condition for
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_extra_route(struct multi_instance *mi);
+
+/**
+ * Determines if the ifconfig_ipv6_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_ipv6_extra_route(struct multi_instance *mi);
+
 /*
  * Check for signals.
  */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 6
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: d12fk <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-MessageType: newpatchset

#15 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, ordex, plaisthos.

Hello flichtenheld, ordex,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email

to look at the new patch set (#7).

Change subject: Install host routes for ifconfig-push routes when DCO is enabled
......................................................................

Install host routes for ifconfig-push routes when DCO is enabled

ifconfig-push and ifconfig-ipv6-push can configure the IP address of a client. If this IP address lies inside the network that is configured on the ovpn/tun device this works as expected as the routing table point to the ovpn/tun interface. However, if the IP address
is outside that range, the IP packets are not forwarded to the ovpn/tun interface.

This patch adds logic to add host routes for these ifconfig-push/ifconfig-ipv6-push addresses to ensure that traffic for these IP addresses is also directed to the VPN.

For Linux it is important that these extra routes are routes using scope link rather than static since otherwise routes via these IP addresses, like iroute, will not work. On FreeBSD we also use interface routes as works and routes that target interfaces instead of IP addresses are less brittle.

Tested using a server with ccd:

   openvpn --server 10.33.0.0 255.255.192.0 --server-ipv6 fd00:f00f::1/64  --client-config-dir ~/ccd [...]

and a client with lwipvonpn and the following ccd file:

iroute-ipv6 FD00:F00F:CAFE::1001/64 ifconfig-ipv6-push FD00:F00F:D00D::77/64
push "setenv-safe ifconfig_ipv6_local_2 FD00:F00F:CAFE::1001" push "setenv-safe ifconfig_ipv6_netbits_2 64"

iroute 10.234.234.0 255.255.255.0 ifconfig-push 10.11.12.13 255.255.255.0 push "setenv-safe ifconfig_local_2 10.234.234.12" push "setenv-safe ifconfig_netmask_2 255.255.255.0"

This setups an ifconfig-push addresses outside the --server/--server-ipv6 network and additionally configures a iroute behind that client. The setenv-safe configure lwipovpn to use that additional IP addresses to allow testing via ping.

Windows behaves like the user space implementation. It does require these special routes but instead (like user space) needs static routes to redirect IP traffic for these IP addresses to the tunnel interface. E.g. in the example above the server config needs to have:

route 10.234.234.0 255.255.255.0
route 10.11.12.0 255.255.255.0

route-ipv6 FD00:F00F:CAFE::1001/64
route-ipv6 FD00:F00F:D00D::77/64

Change-Id I83295e00d1a756dfa44050b0a4493095fb050fff

---
M doc/man-sections/server-options.rst
M src/openvpn/dco.c
M src/openvpn/mroute.h
M src/openvpn/multi.c
M src/openvpn/multi.h

5 files changed, 147 insertions(+), 7 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1192/7

doc/man-sections/server-options.rst +8 -0
index ccc1374..9c7fa46 100644
@@ -314,6 +314,10 @@
   3.  Use ``--ifconfig-pool`` allocation for dynamic IP (last
       choice).
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig``, OpenVPN will install a /32 host route for the ``local``
+  IP address.
+
 --ifconfig-ipv6-push args
   for ``--client-config-dir`` per-client static IPv6 interface
   configuration, see ``--client-config-dir`` and ``--ifconfig-push`` for
@@ -324,6 +328,10 @@
 
      ifconfig-ipv6-push ipv6addr/bits ipv6remote
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig-ipv6``, OpenVPN will install a /128 host route for the
+  ``ipv6addr`` IP address.
+
 --multihome
   Configure a multi-homed UDP server. This option needs to be used when a
   server has more than one IP address (e.g. multiple interfaces, or
src/openvpn/dco.c +44 -2

77 lines not on this page · raw message

src/openvpn/mroute.h +4 -0
index 5b0c694..afd2e6c 100644
@@ -20,6 +20,7 @@
  *  with this program; if not, see <https://www.gnu.org/licenses/>.
  */
 
+
 #ifndef MROUTE_H
 #define MROUTE_H
 
@@ -74,6 +75,9 @@
 /* Address type mask indicating that proto # is part of address */
 #define MR_WITH_PROTO 32
 
+/* MRoute is an on link/scope address needed for DCO on Unix platforms */
+#define MR_ONLINK_DCO_ADDR 64
+
 struct mroute_addr
 {
     uint8_t len;     /* length of address */
src/openvpn/multi.c +69 -5

97 lines not on this page · raw message

src/openvpn/multi.h +22 -0
index 087c0e6..bc58d38 100644
@@ -666,6 +666,28 @@
     return ret;
 }
 
+/**
+ * Determines if the ifconfig_push_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @param mi           The multi-instance to check this condition for
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_extra_route(struct multi_instance *mi);
+
+/**
+ * Determines if the ifconfig_ipv6_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_ipv6_extra_route(struct multi_instance *mi);
+
 /*
  * Check for signals.
  */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 7
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: d12fk <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-MessageType: newpatchset

#16 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, ordex, plaisthos.

d12fk has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes for ifconfig-push routes when DCO is enabled
......................................................................

Patch Set 4:

(1 comment)

File src/openvpn/multi.c:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/6c873af0_913f1b52 :
PS2, Line 4347: /**

Quoted 1 line

Doxygen is already in the header file

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: d12fk <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Thu, 18 Sep 2025 03:14:42 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: d12fk <[email protected]...>
Gerrit-MessageType: comment

#17 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

Attention is currently required from: flichtenheld, ordex, plaisthos.

d12fk has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes for ifconfig-push routes when DCO is enabled
......................................................................

Patch Set 7: Code-Review+1

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 7
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Thu, 18 Sep 2025 03:16:17 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#18 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

Attention is currently required from: flichtenheld, ordex, plaisthos.

cron2 has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes for ifconfig-push routes when DCO is enabled
......................................................................

Patch Set 8: Code-Review-2

(5 comments)

Patchset:

PS8:
this got broken during review / respin... conceptually I have nothing to complain, but the MR_ONLINK_ADDR vs. MR_ONLINK_DCO_ADDR needs to be fixed. Admittedly I do not understand why it compiles at all (!?)...

```
$ git grep MR_ONLINK
src/openvpn/dco.c:    if (addr->type & MR_ONLINK_DCO_ADDR)
src/openvpn/dco.c:        if (addr->type & MR_ONLINK_ADDR)
src/openvpn/dco.c:        if (addr->type & MR_ONLINK_ADDR)
src/openvpn/mroute.h:#define MR_ONLINK_DCO_ADDR 64
src/openvpn/multi.c:        addr.type |= MR_ONLINK_DCO_ADDR;
src/openvpn/multi.c:        addr.type |= MR_ONLINK_DCO_ADDR;
```

so MR_ONLINK_ADDR is referenced, but not defined anywhere - and it still compiles. Huh.

File src/openvpn/dco.c:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/785dfadb_41bb07c6?usp=email :
PS8, Line 686:
This got broken in patch iterations - initially everything was MR_ONLINK_ADDR and then the define got changed to MR_ONLINK_DCO_ADDR but the "not win32" platform was not adjusted?

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/c26431d1_ead0937a?usp=email :
PS8, Line 700: if (addr->type & MR_ONLINK_ADDR)
_DCO_

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/b9ffbe40_0e0e1234?usp=email :
PS8, Line 745: }
this looks wrong. The !not WIN32 code calls dco_win_?

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/6e19a3ae_10206ebe?usp=email :
PS8, Line 771: }
This is asymmetric to IPv4 - I guess this is from early tests, and the dco_win_del...() think needs to go out?

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 8
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Sun, 12 Oct 2025 12:55:11 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

#19 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

Attention is currently required from: flichtenheld, ordex, plaisthos.

cron2 has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes for ifconfig-push routes when DCO is enabled
......................................................................

Patch Set 8:

(1 comment)

Patchset:

PS8:
Ah, it compiles because that particular test instance had configure --disable-dco. If configured without that, compilation bombs in the expected way

```
  CC       dco.o
dco.c: In function 'dco_install_iroute':
dco.c:683:26: error: 'MR_ONLINK_ADDR' undeclared (first use in this function); did you mean 'MR_ONLINK_DCO_ADDR'?
  683 |         if (addr->type & MR_ONLINK_ADDR)
      |                          ^~~~~~~~~~~~~~
      |                          MR_ONLINK_DCO_ADDR
dco.c:683:26: note: each undeclared identifier is reported only once for each function it appears in
dco.c: In function 'dco_delete_iroutes':
dco.c:744:13: error: implicit declaration of function 'dco_win_del_iroute_ipv4' [-Wimplicit-function-declaration]
  744 |             dco_win_del_iroute_ipv4(&c->c1.tuntap->dco, mi->context.c2.push_ifconfig_local, 32);
      |             ^~~~~~~~~~~~~~~~~~~~~~~
```

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 8
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Sun, 12 Oct 2025 12:59:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No

#20 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld, ordex.

plaisthos has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes for ifconfig-push routes when DCO is enabled
......................................................................

Patch Set 8:

(5 comments)

Patchset:

PS8:

Quoted 1 line

this got broken during review / respin... […]

Yeah not really sure what happend there during my rebase. I am going through the patch again to see that it really works.

File src/openvpn/dco.c:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/1d9fd552_43ebda64?usp=email :
PS8, Line 686:

Quoted 1 line

This got broken in patch iterations - initially everything was MR_ONLINK_ADDR and then the define […]

Acknowledged

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/394a8910_234e7857?usp=email :
PS8, Line 700: if (addr->type & MR_ONLINK_ADDR)

Quoted 1 line

_DCO_

Done

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/d3123254_400e84c7?usp=email :
PS8, Line 745: }

Quoted 1 line

this looks wrong. […]

Done

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/fba68590_cdaa0d71?usp=email :
PS8, Line 771: }

Quoted 1 line

This is asymmetric to IPv4 - I guess this is from early tests, and the `dco_win_del... […]

Acknowledged

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 8
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Mon, 13 Oct 2025 14:23:56 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>

#21 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

Attention is currently required from: cron2, d12fk, flichtenheld, ordex.

Hello cron2, d12fk, flichtenheld, ordex,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email

to look at the new patch set (#9).

The following approvals got outdated and were removed:
Code-Review+1 by d12fk

Change subject: Install host routes for ifconfig-push routes when DCO is enabled
......................................................................

Install host routes for ifconfig-push routes when DCO is enabled

ifconfig-push and ifconfig-ipv6-push can configure the IP address of a client. If this IP address lies inside the network that is configured on the ovpn/tun device this works as expected as the routing table point to the ovpn/tun interface. However, if the IP address
is outside that range, the IP packets are not forwarded to the ovpn/tun interface.

This patch adds logic to add host routes for these ifconfig-push/ifconfig-ipv6-push addresses to ensure that traffic for these IP addresses is also directed to the VPN.

For Linux it is important that these extra routes are routes using scope link rather than static since otherwise routes via these IP addresses, like iroute, will not work. On FreeBSD we also use interface routes as works and routes that target interfaces instead of IP addresses are less brittle.

Tested using a server with ccd:

   openvpn --server 10.33.0.0 255.255.192.0 --server-ipv6 fd00:f00f::1/64  --client-config-dir ~/ccd [...]

and a client with lwipvonpn and the following ccd file:

iroute-ipv6 FD00:F00F:CAFE::1001/64 ifconfig-ipv6-push FD00:F00F:D00D::77/64
push "setenv-safe ifconfig_ipv6_local_2 FD00:F00F:CAFE::1001" push "setenv-safe ifconfig_ipv6_netbits_2 64"

iroute 10.234.234.0 255.255.255.0 ifconfig-push 10.11.12.13 255.255.255.0 push "setenv-safe ifconfig_local_2 10.234.234.12" push "setenv-safe ifconfig_netmask_2 255.255.255.0"

This setups an ifconfig-push addresses outside the --server/--server-ipv6 network and additionally configures a iroute behind that client. The setenv-safe configure lwipovpn to use that additional IP addresses to allow testing via ping.

Windows behaves like the user space implementation. It does require these special routes but instead (like user space) needs static routes to redirect IP traffic for these IP addresses to the tunnel interface. E.g. in the example above the server config needs to have:

route 10.234.234.0 255.255.255.0
route 10.11.12.0 255.255.255.0

route-ipv6 FD00:F00F:CAFE::1001/64
route-ipv6 FD00:F00F:D00D::77/64

Change-Id I83295e00d1a756dfa44050b0a4493095fb050fff

---
M doc/man-sections/server-options.rst
M src/openvpn/dco.c
M src/openvpn/mroute.h
M src/openvpn/multi.c
M src/openvpn/multi.h

5 files changed, 148 insertions(+), 7 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1192/9

doc/man-sections/server-options.rst +8 -0
index ccc1374..9c7fa46 100644
@@ -314,6 +314,10 @@
   3.  Use ``--ifconfig-pool`` allocation for dynamic IP (last
       choice).
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig``, OpenVPN will install a /32 host route for the ``local``
+  IP address.
+
 --ifconfig-ipv6-push args
   for ``--client-config-dir`` per-client static IPv6 interface
   configuration, see ``--client-config-dir`` and ``--ifconfig-push`` for
@@ -324,6 +328,10 @@
 
      ifconfig-ipv6-push ipv6addr/bits ipv6remote
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig-ipv6``, OpenVPN will install a /128 host route for the
+  ``ipv6addr`` IP address.
+
 --multihome
   Configure a multi-homed UDP server. This option needs to be used when a
   server has more than one IP address (e.g. multiple interfaces, or
src/openvpn/dco.c +45 -2

78 lines not on this page · raw message

src/openvpn/mroute.h +4 -0
index 5b0c694..afd2e6c 100644
@@ -20,6 +20,7 @@
  *  with this program; if not, see <https://www.gnu.org/licenses/>.
  */
 
+
 #ifndef MROUTE_H
 #define MROUTE_H
 
@@ -74,6 +75,9 @@
 /* Address type mask indicating that proto # is part of address */
 #define MR_WITH_PROTO 32
 
+/* MRoute is an on link/scope address needed for DCO on Unix platforms */
+#define MR_ONLINK_DCO_ADDR 64
+
 struct mroute_addr
 {
     uint8_t len;     /* length of address */
src/openvpn/multi.c +69 -5

97 lines not on this page · raw message

src/openvpn/multi.h +22 -0
index b2b892b..cb9b27b 100644
@@ -666,6 +666,28 @@
     return ret;
 }
 
+/**
+ * Determines if the ifconfig_push_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @param mi           The multi-instance to check this condition for
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_extra_route(struct multi_instance *mi);
+
+/**
+ * Determines if the ifconfig_ipv6_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_ipv6_extra_route(struct multi_instance *mi);
+
 /*
  * Check for signals.
  */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 9
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>

#22 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

Attention is currently required from: cron2, d12fk, flichtenheld, ordex.

Hello cron2, d12fk, flichtenheld, ordex,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email

to look at the new patch set (#10).

Change subject: Install host routes for ifconfig-push routes when DCO is enabled
......................................................................

Install host routes for ifconfig-push routes when DCO is enabled

ifconfig-push and ifconfig-ipv6-push can configure the IP address of a client. If this IP address lies inside the network that is configured on the ovpn/tun device this works as expected as the routing table point to the ovpn/tun interface. However, if the IP address
is outside that range, the IP packets are not forwarded to the ovpn/tun interface.

This patch adds logic to add host routes for these ifconfig-push/ifconfig-ipv6-push addresses to ensure that traffic for these IP addresses is also directed to the VPN.

For Linux it is important that these extra routes are routes using scope link rather than static since otherwise routes via these IP addresses, like iroute, will not work. On FreeBSD we also use interface routes as works and routes that target interfaces instead of IP addresses are less brittle.

Tested using a server with ccd:

   openvpn --server 10.33.0.0 255.255.192.0 --server-ipv6 fd00:f00f::1/64  --client-config-dir ~/ccd [...]

and a client with lwipvonpn and the following ccd file:

iroute-ipv6 FD00:F00F:CAFE::1001/64 ifconfig-ipv6-push FD00:F00F:D00D::77/64
push "setenv-safe ifconfig_ipv6_local_2 FD00:F00F:CAFE::1001" push "setenv-safe ifconfig_ipv6_netbits_2 64"

iroute 10.234.234.0 255.255.255.0 ifconfig-push 10.11.12.13 255.255.255.0 push "setenv-safe ifconfig_local_2 10.234.234.12" push "setenv-safe ifconfig_netmask_2 255.255.255.0"

This setups an ifconfig-push addresses outside the --server/--server-ipv6 network and additionally configures a iroute behind that client. The setenv-safe configure lwipovpn to use that additional IP addresses to allow testing via ping.

Windows behaves like the user space implementation. It does require these special routes but instead (like user space) needs static routes to redirect IP traffic for these IP addresses to the tunnel interface. E.g. in the example above the server config needs to have:

route 10.234.234.0 255.255.255.0
route 10.11.12.0 255.255.255.0

route-ipv6 FD00:F00F:CAFE::1001/64
route-ipv6 FD00:F00F:D00D::77/64

Change-Id I83295e00d1a756dfa44050b0a4493095fb050fff

---
M doc/man-sections/server-options.rst
M src/openvpn/dco.c
M src/openvpn/mroute.h
M src/openvpn/multi.c
M src/openvpn/multi.h

5 files changed, 148 insertions(+), 7 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1192/10

doc/man-sections/server-options.rst +8 -0
index ccc1374..9c7fa46 100644
@@ -314,6 +314,10 @@
   3.  Use ``--ifconfig-pool`` allocation for dynamic IP (last
       choice).
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig``, OpenVPN will install a /32 host route for the ``local``
+  IP address.
+
 --ifconfig-ipv6-push args
   for ``--client-config-dir`` per-client static IPv6 interface
   configuration, see ``--client-config-dir`` and ``--ifconfig-push`` for
@@ -324,6 +328,10 @@
 
      ifconfig-ipv6-push ipv6addr/bits ipv6remote
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig-ipv6``, OpenVPN will install a /128 host route for the
+  ``ipv6addr`` IP address.
+
 --multihome
   Configure a multi-homed UDP server. This option needs to be used when a
   server has more than one IP address (e.g. multiple interfaces, or
src/openvpn/dco.c +45 -2

78 lines not on this page · raw message

src/openvpn/mroute.h +4 -0
index 5b0c694..afd2e6c 100644
@@ -20,6 +20,7 @@
  *  with this program; if not, see <https://www.gnu.org/licenses/>.
  */
 
+
 #ifndef MROUTE_H
 #define MROUTE_H
 
@@ -74,6 +75,9 @@
 /* Address type mask indicating that proto # is part of address */
 #define MR_WITH_PROTO 32
 
+/* MRoute is an on link/scope address needed for DCO on Unix platforms */
+#define MR_ONLINK_DCO_ADDR 64
+
 struct mroute_addr
 {
     uint8_t len;     /* length of address */
src/openvpn/multi.c +69 -5

97 lines not on this page · raw message

src/openvpn/multi.h +22 -0
index b2b892b..cb9b27b 100644
@@ -666,6 +666,28 @@
     return ret;
 }
 
+/**
+ * Determines if the ifconfig_push_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @param mi           The multi-instance to check this condition for
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_extra_route(struct multi_instance *mi);
+
+/**
+ * Determines if the ifconfig_ipv6_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_ipv6_extra_route(struct multi_instance *mi);
+
 /*
  * Check for signals.
  */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 10
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>

#23 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, ordex, plaisthos.

cron2 has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes for ifconfig-push routes when DCO is enabled
......................................................................

Patch Set 11: Code-Review-2

(1 comment)

Patchset:

PS11:
This is not working right yet. I am testing on FreeBSD/DCO, but the "do I need this route" logic should not make a difference.

I've built a testbed to create ifconfig-push or ifconfig-ipv6-push at will (from the client side) and integrate that in t_client.sh - and noticed that I am always seeing IPv6 /128s added

```
/sbin/route -6 add -net fd00:abcd:114:2::1001/128 -iface tun0 -fib 0
```

... for a client that just got a pool address

```
# grep ^server tun-udp-p2mp/server.conf
server 10.114.2.0 255.255.255.0
server-ipv6 fd00:abcd:114:2::/64
```

will investigate more tomorrow, but maybe you can find it over night? ;-)

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 11
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Sat, 18 Oct 2025 21:18:40 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

#24 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, ordex, plaisthos.

cron2 has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes for ifconfig-push routes when DCO is enabled
......................................................................

Patch Set 11:

(1 comment)

File src/openvpn/multi.c:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/55223ae1_ab140e86?usp=email :
PS11, Line 4377: &o->push_ifconfig_ipv6_local));
Ah, here we go. This fails if there is *no* ifconfig-ipv6-push in the config, as then we have

```
(gdb) print o->push_ifconfig_ipv6_local
$10 = {__u6_addr = {__u6_addr8 = '\000' <repeats 15 times>, __u6_addr16 = {0, 0, 0, 0, 0, 0, 0, 0}, __u6_addr32 = {0, 0, 0, 0}}}
```

... and that obviously does not match.

From reading the code in dco_delete_iroutes(), this looks as if the check should be on mi->context.c2.push_ifconfig_local and not mi->context.options.push_ifconfig_ipv6_local?

... later... yep, this works:

```
    struct context_2 *c2 = &mi->context.c2;
    return (!ipv6_net_contains_host(&ifconfig_local, o->ifconfig_ipv6_netbits,
                                    &c2->push_ifconfig_ipv6_local));
```

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 11
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Sun, 19 Oct 2025 09:49:39 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No

#25 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, ordex, plaisthos.

cron2 has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes for ifconfig-push routes when DCO is enabled
......................................................................

Patch Set 11:

(1 comment)

File src/openvpn/multi.c:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/e8420035_d33ff056?usp=email :
PS11, Line 4377: &o->push_ifconfig_ipv6_local));

Quoted 1 line

Ah, here we go. This fails if there is *no* ifconfig-ipv6-push in the config, as then we have […]

Maybe it would also be an idea to change multi_check_push_ifconfig_ipv6_extra_route() to not be passed a mi but the actual route we want to check? Both callers know what IPv6 address they want to be looked at (a6 / &mi->context.c2.push_ifconfig_ipv6_local) and actually passing *that* address would certainly make the code easier to understand...

(For symmetry reasons, the same argument could be made for IPv4, of course)

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 11
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Sun, 19 Oct 2025 09:56:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>

#26 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, ordex, plaisthos.

Hello cron2, d12fk, flichtenheld, ordex,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email

to look at the new patch set (#12).

Change subject: Install host routes for ifconfig-push routes when DCO is enabled
......................................................................

Install host routes for ifconfig-push routes when DCO is enabled

ifconfig-push and ifconfig-ipv6-push can configure the IP address of a client. If this IP address lies inside the network that is configured on the ovpn/tun device this works as expected as the routing table point to the ovpn/tun interface. However, if the IP address
is outside that range, the IP packets are not forwarded to the ovpn/tun interface.

This patch adds logic to add host routes for these ifconfig-push/ifconfig-ipv6-push addresses to ensure that traffic for these IP addresses is also directed to the VPN.

For Linux it is important that these extra routes are routes using scope link rather than static since otherwise routes via these IP addresses, like iroute, will not work. On FreeBSD we also use interface routes as works and routes that target interfaces instead of IP addresses are less brittle.

Tested using a server with ccd:

   openvpn --server 10.33.0.0 255.255.192.0 --server-ipv6 fd00:f00f::1/64  --client-config-dir ~/ccd [...]

and a client with lwipvonpn and the following ccd file:

iroute-ipv6 FD00:F00F:CAFE::1001/64 ifconfig-ipv6-push FD00:F00F:D00D::77/64
push "setenv-safe ifconfig_ipv6_local_2 FD00:F00F:CAFE::1001" push "setenv-safe ifconfig_ipv6_netbits_2 64"

iroute 10.234.234.0 255.255.255.0 ifconfig-push 10.11.12.13 255.255.255.0 push "setenv-safe ifconfig_local_2 10.234.234.12" push "setenv-safe ifconfig_netmask_2 255.255.255.0"

This setups an ifconfig-push addresses outside the --server/--server-ipv6 network and additionally configures a iroute behind that client. The setenv-safe configure lwipovpn to use that additional IP addresses to allow testing via ping.

Windows behaves like the user space implementation. It does require these special routes but instead (like user space) needs static routes to redirect IP traffic for these IP addresses to the tunnel interface. E.g. in the example above the server config needs to have:

route 10.234.234.0 255.255.255.0
route 10.11.12.0 255.255.255.0

route-ipv6 FD00:F00F:CAFE::1001/64
route-ipv6 FD00:F00F:D00D::77/64

Change-Id I83295e00d1a756dfa44050b0a4493095fb050fff

---
M doc/man-sections/server-options.rst
M src/openvpn/dco.c
M src/openvpn/mroute.h
M src/openvpn/multi.c
M src/openvpn/multi.h

5 files changed, 152 insertions(+), 7 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1192/12

doc/man-sections/server-options.rst +8 -0
index ccc1374..9c7fa46 100644
@@ -314,6 +314,10 @@
   3.  Use ``--ifconfig-pool`` allocation for dynamic IP (last
       choice).
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig``, OpenVPN will install a /32 host route for the ``local``
+  IP address.
+
 --ifconfig-ipv6-push args
   for ``--client-config-dir`` per-client static IPv6 interface
   configuration, see ``--client-config-dir`` and ``--ifconfig-push`` for
@@ -324,6 +328,10 @@
 
      ifconfig-ipv6-push ipv6addr/bits ipv6remote
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig-ipv6``, OpenVPN will install a /128 host route for the
+  ``ipv6addr`` IP address.
+
 --multihome
   Configure a multi-homed UDP server. This option needs to be used when a
   server has more than one IP address (e.g. multiple interfaces, or
src/openvpn/dco.c +48 -2

81 lines not on this page · raw message

src/openvpn/mroute.h +4 -0
index 5b0c694..afd2e6c 100644
@@ -20,6 +20,7 @@
  *  with this program; if not, see <https://www.gnu.org/licenses/>.
  */
 
+
 #ifndef MROUTE_H
 #define MROUTE_H
 
@@ -74,6 +75,9 @@
 /* Address type mask indicating that proto # is part of address */
 #define MR_WITH_PROTO 32
 
+/* MRoute is an on link/scope address needed for DCO on Unix platforms */
+#define MR_ONLINK_DCO_ADDR 64
+
 struct mroute_addr
 {
     uint8_t len;     /* length of address */
src/openvpn/multi.c +69 -5

97 lines not on this page · raw message

src/openvpn/multi.h +23 -0
index 594ea3a..a26514d 100644
@@ -665,6 +665,29 @@
     return ret;
 }
 
+/**
+ * Determines if the ifconfig_push_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @param mi           The multi-instance to check this condition for
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_extra_route(struct multi_instance *mi, in_addr_t dest);
+
+/**
+ * Determines if the ifconfig_ipv6_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_ipv6_extra_route(struct multi_instance *mi,
+                                           struct in6_addr *dest);
+
 /*
  * Check for signals.
  */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 12
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>

#27 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, ordex, plaisthos.

Hello cron2, d12fk, flichtenheld, ordex,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email

to look at the new patch set (#13).

Change subject: Install host routes for ifconfig-push routes when DCO is enabled
......................................................................

Install host routes for ifconfig-push routes when DCO is enabled

ifconfig-push and ifconfig-ipv6-push can configure the IP address of a client. If this IP address lies inside the network that is configured on the ovpn/tun device this works as expected as the routing table point to the ovpn/tun interface. However, if the IP address
is outside that range, the IP packets are not forwarded to the ovpn/tun interface.

This patch adds logic to add host routes for these ifconfig-push/ifconfig-ipv6-push addresses to ensure that traffic for these IP addresses is also directed to the VPN.

For Linux it is important that these extra routes are routes using scope link rather than static since otherwise routes via these IP addresses, like iroute, will not work. On FreeBSD we also use interface routes as works and routes that target interfaces instead of IP addresses are less brittle.

Tested using a server with ccd:

   openvpn --server 10.33.0.0 255.255.192.0 --server-ipv6 fd00:f00f::1/64  --client-config-dir ~/ccd [...]

and a client with lwipvonpn and the following ccd file:

iroute-ipv6 FD00:F00F:CAFE::1001/64 ifconfig-ipv6-push FD00:F00F:D00D::77/64
push "setenv-safe ifconfig_ipv6_local_2 FD00:F00F:CAFE::1001" push "setenv-safe ifconfig_ipv6_netbits_2 64"

iroute 10.234.234.0 255.255.255.0 ifconfig-push 10.11.12.13 255.255.255.0 push "setenv-safe ifconfig_local_2 10.234.234.12" push "setenv-safe ifconfig_netmask_2 255.255.255.0"

This setups an ifconfig-push addresses outside the --server/--server-ipv6 network and additionally configures a iroute behind that client. The setenv-safe configure lwipovpn to use that additional IP addresses to allow testing via ping.

Windows behaves like the user space implementation. It does require these special routes but instead (like user space) needs static routes to redirect IP traffic for these IP addresses to the tunnel interface. E.g. in the example above the server config needs to have:

route 10.234.234.0 255.255.255.0
route 10.11.12.0 255.255.255.0

route-ipv6 FD00:F00F:CAFE::1001/64
route-ipv6 FD00:F00F:D00D::77/64

Change-Id I83295e00d1a756dfa44050b0a4493095fb050fff

---
M doc/man-sections/server-options.rst
M src/openvpn/dco.c
M src/openvpn/mroute.h
M src/openvpn/multi.c
M src/openvpn/multi.h

5 files changed, 156 insertions(+), 7 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1192/13

doc/man-sections/server-options.rst +8 -0
index ccc1374..9c7fa46 100644
@@ -314,6 +314,10 @@
   3.  Use ``--ifconfig-pool`` allocation for dynamic IP (last
       choice).
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig``, OpenVPN will install a /32 host route for the ``local``
+  IP address.
+
 --ifconfig-ipv6-push args
   for ``--client-config-dir`` per-client static IPv6 interface
   configuration, see ``--client-config-dir`` and ``--ifconfig-push`` for
@@ -324,6 +328,10 @@
 
      ifconfig-ipv6-push ipv6addr/bits ipv6remote
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig-ipv6``, OpenVPN will install a /128 host route for the
+  ``ipv6addr`` IP address.
+
 --multihome
   Configure a multi-homed UDP server. This option needs to be used when a
   server has more than one IP address (e.g. multiple interfaces, or
src/openvpn/dco.c +48 -2

81 lines not on this page · raw message

src/openvpn/mroute.h +4 -0
index 5b0c694..afd2e6c 100644
@@ -20,6 +20,7 @@
  *  with this program; if not, see <https://www.gnu.org/licenses/>.
  */
 
+
 #ifndef MROUTE_H
 #define MROUTE_H
 
@@ -74,6 +75,9 @@
 /* Address type mask indicating that proto # is part of address */
 #define MR_WITH_PROTO 32
 
+/* MRoute is an on link/scope address needed for DCO on Unix platforms */
+#define MR_ONLINK_DCO_ADDR 64
+
 struct mroute_addr
 {
     uint8_t len;     /* length of address */
src/openvpn/multi.c +69 -5

97 lines not on this page · raw message

src/openvpn/multi.h +27 -0
index 594ea3a..2fbb433 100644
@@ -665,6 +665,33 @@
     return ret;
 }
 
+/**
+ * Determines if the ifconfig_push_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @param mi           The multi-instance to check this condition for
+ * @param dest         The destination IP address to check
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_extra_route(struct multi_instance *mi, in_addr_t dest);
+
+/**
+ * Determines if the ifconfig_ipv6_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @param mi           The multi-instance to check this condition for
+ * @param dest         The destination IPv6 address to check
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_ipv6_extra_route(struct multi_instance *mi,
+                                           struct in6_addr *dest);
+
 /*
  * Check for signals.
  */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 13
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>

#28 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, ordex, plaisthos.

cron2 has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes for ifconfig-push routes when DCO is enabled
......................................................................

Patch Set 13: Code-Review-2

(1 comment)

Patchset:

PS13:
We are getting there, but the journey is not over, alas.

Now installation/removal of routes "according to what we want" in general works fine, but we *always* try to remove the IPv4 host route at the end - here's for a regular pool IP:

```
Oct 28 14:25:08 fbsd14 tun-udp-p2mp[12610]: MULTI_sva: pool returned IPv4=10.114.2.3, IPv6=fd00:abcd:114:2::1001
Oct 28 14:25:08 fbsd14 tun-udp-p2mp[12610]: MULTI: Learn: 10.114.2.3 -> cron2-ubuntu-2004-amd64/udp6:195.30.8.84:44555 peer-id=1
Oct 28 14:25:08 fbsd14 tun-udp-p2mp[12610]: MULTI: primary virtual IP for cron2-ubuntu-2004-amd64/udp6:195.30.8.84:44555 peer-id=1: 10.114.2.3
...
Oct 28 14:26:25 fbsd14 tun-udp-p2mp[12610]: /sbin/route del -net 10.114.2.3/32 -iface tun0 -fib 0 -weight 16777115
Oct 28 14:26:25 fbsd14 tun-udp-p2mp[12610]: ERROR: FreeBSD route command failed: external program exited with error status: 1
```

which obviously is not the way to go forward. Need to look what changed in IPv4 land here.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 13
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Tue, 28 Oct 2025 13:32:29 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

#29 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, ordex, plaisthos.

cron2 has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes for ifconfig-push routes when DCO is enabled
......................................................................

Patch Set 13:

(2 comments)

Patchset:

PS13:
found it, htonl() again, the two calls are not symmetric wrt byte order - so the check works correctly for IPv4 add and fails for IPv4 delete. Patch suggestion in the comment.

File src/openvpn/dco.c:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/9082ac20_ae5adc12?usp=email :
PS13, Line 743: if (multi_check_push_ifconfig_extra_route(mi, ifconfig_local))
with patch v12, multi_check_push_ifconfig_extra_route() lost an htonl(), and the *other* caller has a htonl(a), so this one needs a htonl(ifconfig_local) to make it symmetric, or change it everywhere.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 13
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Tue, 28 Oct 2025 13:54:18 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No

#30 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, ordex, plaisthos.

cron2 has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes for ifconfig-push routes when DCO is enabled
......................................................................

Patch Set 13:

(6 comments)

Patchset:

PS8:

Quoted 1 line

Yeah not really sure what happend there during my rebase. […]

Done

Patchset:

PS11:

Quoted 1 line

This is not working right yet. […]

Done

Commit Message:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/4477c2fa_904f1747?usp=email :
PS4, Line 7: Install host routes with onlink scope iroutes for ifconfig-push routes

Quoted 1 line

how about: […]

Done

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/f9794219_e00d035b?usp=email :
PS4, Line 10: of the configured device need to be added to the operating system to

Quoted 1 line

I agree with that, but what I meant in my comment is that we "need *routes* to be added" not IPs. […]

Done

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/220f5023_3980d1f4?usp=email :
PS4, Line 15: iroute, will not work.

Quoted 1 line

should we add "because the server does not have an address in the same network as these IPs assigned […]

Done

File src/openvpn/multi.c:

http://gerrit.openvpn.net/c/openvpn/+/1192/comment/02b58eff_bb2dd3f8?usp=email :
PS11, Line 4377: &o->push_ifconfig_ipv6_local));

Quoted 1 line

Maybe it would also be an idea to change multi_check_push_ifconfig_ipv6_extra_route() to not be pa […]

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 13
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Tue, 28 Oct 2025 13:55:11 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: plaisthos <[email protected]...>
Comment-In-Reply-To: cron2 <[email protected]...>
Comment-In-Reply-To: ordex <[email protected]...>

#31 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, ordex, plaisthos.

Hello cron2, d12fk, flichtenheld, ordex,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email

to look at the new patch set (#14).

Change subject: Install host routes for ifconfig-push routes when DCO is enabled
......................................................................

Install host routes for ifconfig-push routes when DCO is enabled

ifconfig-push and ifconfig-ipv6-push can configure the IP address of a client. If this IP address lies inside the network that is configured on the ovpn/tun device this works as expected as the routing table point to the ovpn/tun interface. However, if the IP address
is outside that range, the IP packets are not forwarded to the ovpn/tun interface.

This patch adds logic to add host routes for these ifconfig-push/ifconfig-ipv6-push addresses to ensure that traffic for these IP addresses is also directed to the VPN.

For Linux it is important that these extra routes are routes using scope link rather than static since otherwise routes via these IP addresses, like iroute, will not work. On FreeBSD we also use interface routes as works and routes that target interfaces instead of IP addresses are less brittle.

Tested using a server with ccd:

   openvpn --server 10.33.0.0 255.255.192.0 --server-ipv6 fd00:f00f::1/64  --client-config-dir ~/ccd [...]

and a client with lwipvonpn and the following ccd file:

iroute-ipv6 FD00:F00F:CAFE::1001/64 ifconfig-ipv6-push FD00:F00F:D00D::77/64
push "setenv-safe ifconfig_ipv6_local_2 FD00:F00F:CAFE::1001" push "setenv-safe ifconfig_ipv6_netbits_2 64"

iroute 10.234.234.0 255.255.255.0 ifconfig-push 10.11.12.13 255.255.255.0 push "setenv-safe ifconfig_local_2 10.234.234.12" push "setenv-safe ifconfig_netmask_2 255.255.255.0"

This setups an ifconfig-push addresses outside the --server/--server-ipv6 network and additionally configures a iroute behind that client. The setenv-safe configure lwipovpn to use that additional IP addresses to allow testing via ping.

Windows behaves like the user space implementation. It does require these special routes but instead (like user space) needs static routes to redirect IP traffic for these IP addresses to the tunnel interface. E.g. in the example above the server config needs to have:

route 10.234.234.0 255.255.255.0
route 10.11.12.0 255.255.255.0

route-ipv6 FD00:F00F:CAFE::1001/64
route-ipv6 FD00:F00F:D00D::77/64

Change-Id I83295e00d1a756dfa44050b0a4493095fb050fff

---
M doc/man-sections/server-options.rst
M src/openvpn/dco.c
M src/openvpn/mroute.h
M src/openvpn/multi.c
M src/openvpn/multi.h

5 files changed, 156 insertions(+), 7 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1192/14

doc/man-sections/server-options.rst +8 -0
index ccc1374..9c7fa46 100644
@@ -314,6 +314,10 @@
   3.  Use ``--ifconfig-pool`` allocation for dynamic IP (last
       choice).
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig``, OpenVPN will install a /32 host route for the ``local``
+  IP address.
+
 --ifconfig-ipv6-push args
   for ``--client-config-dir`` per-client static IPv6 interface
   configuration, see ``--client-config-dir`` and ``--ifconfig-push`` for
@@ -324,6 +328,10 @@
 
      ifconfig-ipv6-push ipv6addr/bits ipv6remote
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig-ipv6``, OpenVPN will install a /128 host route for the
+  ``ipv6addr`` IP address.
+
 --multihome
   Configure a multi-homed UDP server. This option needs to be used when a
   server has more than one IP address (e.g. multiple interfaces, or
src/openvpn/dco.c +48 -2

81 lines not on this page · raw message

src/openvpn/mroute.h +4 -0
index 5b0c694..afd2e6c 100644
@@ -20,6 +20,7 @@
  *  with this program; if not, see <https://www.gnu.org/licenses/>.
  */
 
+
 #ifndef MROUTE_H
 #define MROUTE_H
 
@@ -74,6 +75,9 @@
 /* Address type mask indicating that proto # is part of address */
 #define MR_WITH_PROTO 32
 
+/* MRoute is an on link/scope address needed for DCO on Unix platforms */
+#define MR_ONLINK_DCO_ADDR 64
+
 struct mroute_addr
 {
     uint8_t len;     /* length of address */
src/openvpn/multi.c +69 -5

97 lines not on this page · raw message

src/openvpn/multi.h +27 -0
index 594ea3a..2fbb433 100644
@@ -665,6 +665,33 @@
     return ret;
 }
 
+/**
+ * Determines if the ifconfig_push_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @param mi           The multi-instance to check this condition for
+ * @param dest         The destination IP address to check
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_extra_route(struct multi_instance *mi, in_addr_t dest);
+
+/**
+ * Determines if the ifconfig_ipv6_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @param mi           The multi-instance to check this condition for
+ * @param dest         The destination IPv6 address to check
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_ipv6_extra_route(struct multi_instance *mi,
+                                           struct in6_addr *dest);
+
 /*
  * Check for signals.
  */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 14
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>

#32 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, ordex, plaisthos.

cron2 has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes for ifconfig-push routes when DCO is enabled
......................................................................

Patch Set 14: Code-Review+2

(1 comment)

Patchset:

PS14:
thanks :-)

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 14
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Wed, 29 Oct 2025 07:06:44 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

#33 lore raw

PATCH v14 1/1 Install host routes for ifconfig-push routes when DCO is enabled

In reply to a message not in the archive

From: Arne Schwabe <[email protected]...>

ifconfig-push and ifconfig-ipv6-push can configure the IP address of a client. If this IP address lies inside the network that is configured on the ovpn/tun device this works as expected as the routing table point to the ovpn/tun interface. However, if the IP address
is outside that range, the IP packets are not forwarded to the ovpn/tun interface.

This patch adds logic to add host routes for these ifconfig-push/ifconfig-ipv6-push addresses to ensure that traffic for these IP addresses is also directed to the VPN.

For Linux it is important that these extra routes are routes using scope link rather than static since otherwise routes via these IP addresses, like iroute, will not work. On FreeBSD we also use interface routes as works and routes that target interfaces instead of IP addresses are less brittle.

Tested using a server with ccd:

   openvpn --server 10.33.0.0 255.255.192.0 --server-ipv6 fd00:f00f::1/64  --client-config-dir ~/ccd [...]

and a client with lwipvonpn and the following ccd file:

iroute-ipv6 FD00:F00F:CAFE::1001/64 ifconfig-ipv6-push FD00:F00F:D00D::77/64
push "setenv-safe ifconfig_ipv6_local_2 FD00:F00F:CAFE::1001" push "setenv-safe ifconfig_ipv6_netbits_2 64"

iroute 10.234.234.0 255.255.255.0 ifconfig-push 10.11.12.13 255.255.255.0 push "setenv-safe ifconfig_local_2 10.234.234.12" push "setenv-safe ifconfig_netmask_2 255.255.255.0"

This setups an ifconfig-push addresses outside the --server/--server-ipv6 network and additionally configures a iroute behind that client. The setenv-safe configure lwipovpn to use that additional IP addresses to allow testing via ping.

Windows behaves like the user space implementation. It does require these special routes but instead (like user space) needs static routes to redirect IP traffic for these IP addresses to the tunnel interface. E.g. in the example above the server config needs to have:

route 10.234.234.0 255.255.255.0
route 10.11.12.0 255.255.255.0

route-ipv6 FD00:F00F:CAFE::1001/64
route-ipv6 FD00:F00F:D00D::77/64

Change-Id I83295e00d1a756dfa44050b0a4493095fb050fff

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1192
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1192
This mail reflects revision 14 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

doc/man-sections/server-options.rst +8 -0
index ccc1374..9c7fa46 100644
@@ -314,6 +314,10 @@
   3.  Use ``--ifconfig-pool`` allocation for dynamic IP (last
       choice).
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig``, OpenVPN will install a /32 host route for the ``local``
+  IP address.
+
 --ifconfig-ipv6-push args
   for ``--client-config-dir`` per-client static IPv6 interface
   configuration, see ``--client-config-dir`` and ``--ifconfig-push`` for
@@ -324,6 +328,10 @@
 
      ifconfig-ipv6-push ipv6addr/bits ipv6remote
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig-ipv6``, OpenVPN will install a /128 host route for the
+  ``ipv6addr`` IP address.
+
 --multihome
   Configure a multi-homed UDP server. This option needs to be used when a
   server has more than one IP address (e.g. multiple interfaces, or
src/openvpn/dco.c +48 -2

81 lines not on this page · raw message

src/openvpn/mroute.h +4 -0
index 5b0c694..afd2e6c 100644
@@ -20,6 +20,7 @@
  *  with this program; if not, see <https://www.gnu.org/licenses/>.
  */
 
+
 #ifndef MROUTE_H
 #define MROUTE_H
 
@@ -74,6 +75,9 @@
 /* Address type mask indicating that proto # is part of address */
 #define MR_WITH_PROTO 32
 
+/* MRoute is an on link/scope address needed for DCO on Unix platforms */
+#define MR_ONLINK_DCO_ADDR 64
+
 struct mroute_addr
 {
     uint8_t len;     /* length of address */
src/openvpn/multi.c +69 -5

97 lines not on this page · raw message

src/openvpn/multi.h +27 -0
index 594ea3a..2fbb433 100644
@@ -665,6 +665,33 @@
     return ret;
 }
 
+/**
+ * Determines if the ifconfig_push_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @param mi           The multi-instance to check this condition for
+ * @param dest         The destination IP address to check
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_extra_route(struct multi_instance *mi, in_addr_t dest);
+
+/**
+ * Determines if the ifconfig_ipv6_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @param mi           The multi-instance to check this condition for
+ * @param dest         The destination IPv6 address to check
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_ipv6_extra_route(struct multi_instance *mi,
+                                           struct in6_addr *dest);
+
 /*
  * Check for signals.
  */
#34 lore raw

[Openvpn-devel] [PATCH applied] Re: Install host routes for out-of-subnet ifconfig-push addresses when DCO is enabled

Thanks for the midnight fix, just in time for 2.7_rc1 ;-)

So this has been a bit of a journey with the patch running up to v14... getting bits and pieces right across the 3 potentially affected platforms (Linux and FreeBSD need this, Windows has DCO but must not have this) and IPv4/IPv6 is quite a few small snippets all over the place.

I have tested this on FreeBSD with DCO, with a client-connect script that can setup ifconfig-push/ifconfig-ipv6-push/iroute/iroute-ipv6 controlled from the client ("setenv UV_WANT_IP ...") and t_client.rc instances that request IPv4/IPv6 addresses "outside the server subnet", verify that they receive what they asked for, and then run pings to see if traffic actually comes back. This worked already in v11.

v11->v13->v14 was basically ensuring that we only install these routes when we really need them (v11 installed the route "always!" for IPv6 due to checking the wrong variable, v13 always tried to *delete* the route for IPv4 due to missing htonl() in one of the calls). In v14 we now have exactly what we want - routes get only installed when needed, and are only deleted when installed.

There might be dragons lurking here with clients reconnecting and learn/unlearn-address getting confused. I ran my tests with EEN on the client side to ensure the server always has a well-defined state.

I have also reworded the commit message a bit :-)

Your patch has been applied to the master branch.

commit f938d991a8222bb3304865f2cd7b368d7f8a9224

Author: Arne Schwabe
Date:   Wed Oct 29 08:06:56 2025 +0100
     Install host routes for out-of-subnet ifconfig-push addresses when DCO is enabled

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1192
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg33991.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#35 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for out-of-subnet ifconfig-push addresses when DC...

In reply to a message not in the archive

cron2 has uploaded a new patch set (#15) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: Install host routes for out-of-subnet ifconfig-push addresses when DCO is enabled
......................................................................

Install host routes for out-of-subnet ifconfig-push addresses when DCO is enabled

ifconfig-push and ifconfig-ipv6-push can configure the IP address of a client. If this IP address lies inside the network that is configured on the ovpn/tun device this works as expected as the routing table point to the ovpn/tun interface. However, if the IP address is outside that range, the IP packets are not forwarded to the ovpn/tun interface and Linux and FreeBSD DCO implementations need a "connected" route so kernel routing knows that the IP in question is a peer VPN IP.

This patch adds logic to add host routes for these ifconfig-push + ifconfig-ipv6-push addresses to ensure that traffic for these IP addresses is also directed to the VPN.

For Linux it is important that these extra routes are routes using scope link rather than static since otherwise indirect routes via these IP addresses, like iroute, will not work. On FreeBSD we also use interface routes as that works and routes that target interfaces instead of next-hop IP addresses are less brittle.

Tested using a server with ccd:

   openvpn --server 10.33.0.0 255.255.192.0 --server-ipv6 fd00:f00f::1/64  --client-config-dir ~/ccd [...]

and a client with lwipvonpn and the following ccd file:

iroute-ipv6 FD00:F00F:CAFE::1001/64 ifconfig-ipv6-push FD00:F00F:D00D::77/64
push "setenv-safe ifconfig_ipv6_local_2 FD00:F00F:CAFE::1001" push "setenv-safe ifconfig_ipv6_netbits_2 64"

iroute 10.234.234.0 255.255.255.0 ifconfig-push 10.11.12.13 255.255.255.0 push "setenv-safe ifconfig_local_2 10.234.234.12" push "setenv-safe ifconfig_netmask_2 255.255.255.0"

This setups an ifconfig-push addresses outside the --server/--server-ipv6 network and additionally configures a iroute behind that client. The setenv-safe configure lwipovpn to use that additional IP addresses to allow testing via ping.

Windows behaves like the user space implementation. It does not require these special routes but instead (like user space) needs static routes to redirect IP traffic for these IP addresses to the tunnel interface. E.g. in the example above the server config needs to have:

route 10.234.234.0 255.255.255.0
route 10.11.12.0 255.255.255.0

route-ipv6 FD00:F00F:CAFE::1001/64
route-ipv6 FD00:F00F:D00D::77/64

Change-Id I83295e00d1a756dfa44050b0a4493095fb050fff

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1192
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33991.html

---
M doc/man-sections/server-options.rst
M src/openvpn/dco.c
M src/openvpn/mroute.h
M src/openvpn/multi.c
M src/openvpn/multi.h

5 files changed, 156 insertions(+), 7 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1192/15

doc/man-sections/server-options.rst +8 -0
index 347a251..ade4d41 100644
@@ -314,6 +314,10 @@
   3.  Use ``--ifconfig-pool`` allocation for dynamic IP (last
       choice).
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig``, OpenVPN will install a /32 host route for the ``local``
+  IP address.
+
 --ifconfig-ipv6-push args
   for ``--client-config-dir`` per-client static IPv6 interface
   configuration, see ``--client-config-dir`` and ``--ifconfig-push`` for
@@ -324,6 +328,10 @@
 
      ifconfig-ipv6-push ipv6addr/bits ipv6remote
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig-ipv6``, OpenVPN will install a /128 host route for the
+  ``ipv6addr`` IP address.
+
 --multihome
   Configure a multi-homed UDP server. This option needs to be used when a
   server has more than one IP address (e.g. multiple interfaces, or
src/openvpn/dco.c +48 -2

81 lines not on this page · raw message

src/openvpn/mroute.h +4 -0
index 5b0c694..afd2e6c 100644
@@ -20,6 +20,7 @@
  *  with this program; if not, see <https://www.gnu.org/licenses/>.
  */
 
+
 #ifndef MROUTE_H
 #define MROUTE_H
 
@@ -74,6 +75,9 @@
 /* Address type mask indicating that proto # is part of address */
 #define MR_WITH_PROTO 32
 
+/* MRoute is an on link/scope address needed for DCO on Unix platforms */
+#define MR_ONLINK_DCO_ADDR 64
+
 struct mroute_addr
 {
     uint8_t len;     /* length of address */
src/openvpn/multi.c +69 -5

97 lines not on this page · raw message

src/openvpn/multi.h +27 -0
index 50f8d10..a62b07a 100644
@@ -666,6 +666,33 @@
     return ret;
 }
 
+/**
+ * Determines if the ifconfig_push_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @param mi           The multi-instance to check this condition for
+ * @param dest         The destination IP address to check
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_extra_route(struct multi_instance *mi, in_addr_t dest);
+
+/**
+ * Determines if the ifconfig_ipv6_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @param mi           The multi-instance to check this condition for
+ * @param dest         The destination IPv6 address to check
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_ipv6_extra_route(struct multi_instance *mi,
+                                           struct in6_addr *dest);
+
 /*
  * Check for signals.
  */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 15
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#36 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Install host routes for out-of-subnet ifconfig-push addresses when DC...

In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email )

Change subject: Install host routes for out-of-subnet ifconfig-push addresses when DCO is enabled
......................................................................

Install host routes for out-of-subnet ifconfig-push addresses when DCO is enabled

ifconfig-push and ifconfig-ipv6-push can configure the IP address of a client. If this IP address lies inside the network that is configured on the ovpn/tun device this works as expected as the routing table point to the ovpn/tun interface. However, if the IP address is outside that range, the IP packets are not forwarded to the ovpn/tun interface and Linux and FreeBSD DCO implementations need a "connected" route so kernel routing knows that the IP in question is a peer VPN IP.

This patch adds logic to add host routes for these ifconfig-push + ifconfig-ipv6-push addresses to ensure that traffic for these IP addresses is also directed to the VPN.

For Linux it is important that these extra routes are routes using scope link rather than static since otherwise indirect routes via these IP addresses, like iroute, will not work. On FreeBSD we also use interface routes as that works and routes that target interfaces instead of next-hop IP addresses are less brittle.

Tested using a server with ccd:

   openvpn --server 10.33.0.0 255.255.192.0 --server-ipv6 fd00:f00f::1/64  --client-config-dir ~/ccd [...]

and a client with lwipvonpn and the following ccd file:

iroute-ipv6 FD00:F00F:CAFE::1001/64 ifconfig-ipv6-push FD00:F00F:D00D::77/64
push "setenv-safe ifconfig_ipv6_local_2 FD00:F00F:CAFE::1001" push "setenv-safe ifconfig_ipv6_netbits_2 64"

iroute 10.234.234.0 255.255.255.0 ifconfig-push 10.11.12.13 255.255.255.0 push "setenv-safe ifconfig_local_2 10.234.234.12" push "setenv-safe ifconfig_netmask_2 255.255.255.0"

This setups an ifconfig-push addresses outside the --server/--server-ipv6 network and additionally configures a iroute behind that client. The setenv-safe configure lwipovpn to use that additional IP addresses to allow testing via ping.

Windows behaves like the user space implementation. It does not require these special routes but instead (like user space) needs static routes to redirect IP traffic for these IP addresses to the tunnel interface. E.g. in the example above the server config needs to have:

route 10.234.234.0 255.255.255.0
route 10.11.12.0 255.255.255.0

route-ipv6 FD00:F00F:CAFE::1001/64
route-ipv6 FD00:F00F:D00D::77/64

Change-Id I83295e00d1a756dfa44050b0a4493095fb050fff

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1192
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33991.html

---
M doc/man-sections/server-options.rst
M src/openvpn/dco.c
M src/openvpn/mroute.h
M src/openvpn/multi.c
M src/openvpn/multi.h

5 files changed, 156 insertions(+), 7 deletions(-)
doc/man-sections/server-options.rst +8 -0
index 347a251..ade4d41 100644
@@ -314,6 +314,10 @@
   3.  Use ``--ifconfig-pool`` allocation for dynamic IP (last
       choice).
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig``, OpenVPN will install a /32 host route for the ``local``
+  IP address.
+
 --ifconfig-ipv6-push args
   for ``--client-config-dir`` per-client static IPv6 interface
   configuration, see ``--client-config-dir`` and ``--ifconfig-push`` for
@@ -324,6 +328,10 @@
 
      ifconfig-ipv6-push ipv6addr/bits ipv6remote
 
+  When DCO is enabled and the IP is not in contained in the network specified
+  by ``--ifconfig-ipv6``, OpenVPN will install a /128 host route for the
+  ``ipv6addr`` IP address.
+
 --multihome
   Configure a multi-homed UDP server. This option needs to be used when a
   server has more than one IP address (e.g. multiple interfaces, or
src/openvpn/dco.c +48 -2

81 lines not on this page · raw message

src/openvpn/mroute.h +4 -0
index 5b0c694..afd2e6c 100644
@@ -20,6 +20,7 @@
  *  with this program; if not, see <https://www.gnu.org/licenses/>.
  */
 
+
 #ifndef MROUTE_H
 #define MROUTE_H
 
@@ -74,6 +75,9 @@
 /* Address type mask indicating that proto # is part of address */
 #define MR_WITH_PROTO 32
 
+/* MRoute is an on link/scope address needed for DCO on Unix platforms */
+#define MR_ONLINK_DCO_ADDR 64
+
 struct mroute_addr
 {
     uint8_t len;     /* length of address */
src/openvpn/multi.c +69 -5

97 lines not on this page · raw message

src/openvpn/multi.h +27 -0
index 50f8d10..a62b07a 100644
@@ -666,6 +666,33 @@
     return ret;
 }
 
+/**
+ * Determines if the ifconfig_push_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @param mi           The multi-instance to check this condition for
+ * @param dest         The destination IP address to check
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_extra_route(struct multi_instance *mi, in_addr_t dest);
+
+/**
+ * Determines if the ifconfig_ipv6_local address falls into the range of the local
+ * IP addresses of the VPN interface (ifconfig_local with ifconfig_remote_netmask)
+ *
+ * @param mi           The multi-instance to check this condition for
+ * @param dest         The destination IPv6 address to check
+ *
+ * @return Returns true if ifconfig_push is outside that range and requires an extra
+ * route to be installed.
+ */
+bool
+multi_check_push_ifconfig_ipv6_extra_route(struct multi_instance *mi,
+                                           struct in6_addr *dest);
+
 /*
  * Check for signals.
  */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1192?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I83295e00d1a756dfa44050b0a4493095fb050fff
Gerrit-Change-Number: 1192
Gerrit-PatchSet: 15
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>